package com.framework.plm.sec.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.framework.plm.bas.param.GeneralParam;
import com.framework.plm.bas.util.PlmBasConstant;
import com.framework.plm.bas.web.provider.IPlmQueryProvider;

/**
 * @author cuiWenming
 */
@SuppressWarnings("unchecked")
@Controller
@RequestMapping("/sec/user")
public class SecUserController extends AbsPlmSecController {

	private static final long serialVersionUID = 1L;
	//http://localhost:8080/webFramework/sec/user//findUser/2?_req_json_curpageno=3&_req_json_pagesize=5
	@RequestMapping("/findUser/{id}")
	public String findUsers(ModelMap mm,HttpServletRequest request,@PathVariable("id") String userId){
		GeneralParam param=GeneralParam.getCurrent();
		param.setValue("test", "vincent");
		param.setValue(PlmBasConstant.APP_SERVICE, "PLM04010101");
		
//		Object o=runService(param, request);//根据serviceCode执行对应的service，code可以从页面传入
		Map qparams = new HashMap();
		IPlmQueryProvider sqlProvider = getSqlQueryProvider("home_sec.test1", "home_sec.testSize1", qparams);
		List queryResult = sqlProvider.queryPageData(true);
		List<Map<String, String>> results=(List<Map<String, String>>)queryResult.get(0);
		mm.addAttribute("listSize", results.size());
		mm.addAttribute("toalRecord", queryResult.get(1));
		return "main";
	}

}
